package model

type Category struct {
	BaseModel
	Name             string      `gorm:"type:varchar(20);not null" json:"name"`
	ParentCategoryId int32       `json:"parent"`
	ParentCategory   *Category   `json:"-"`
	SubCategory      []*Category `gorm:"foreignKey:ParentCategoryId;references:ID" json:"sub_category"`
	Level            int32       `gorm:"type:int;not null;default:1" json:"level"`
	IsTab            bool        `gorm:"is_tab;default:false;not null" json:"is_tab"`
}

type Brands struct {
	BaseModel
	Name string `gorm:"type:varchar(20);not null;"`
	Logo string `gorm:"type:varchar(200);default'';not null"`
}

type GoodsCategoryBrand struct {
	BaseModel
	CategoryId int32 `gorm:"category_id;type:int;index:idx_category_brand,unique"`
	Category   Category
	BrandsId   int32 `gorm:"type:int;index:idx_category_brand,unique"`
	//Brands     Brands   `gorm:"brandId;foreignkey:BrandId;references:id"`
	Brands Brands
}

// 自定义表名
//func (GoodsCategoryBrand) TableName() string {
//	return "goodscategorybrand"
//}

type Banner struct {
	BaseModel
	Image string `gorm:"image; type:varchar(200);not null"`
	Url   string `gorm:"type:varchar(200);default:'';not null"`
	Index int32  `gorm:"type:int;default:1;not null"`
}

type Goods struct {
	BaseModel
	CategoryId int32    `gorm:"category_id; type:int;not null"`
	Category   Category `gorm:"category;foreignkey:CategoryId;references:id"`
	BrandsId   int32    `gorm:"type:int;not null"`
	Brands     Brands

	OnSale          bool    `gorm:"default:false;not null;comment:是否上架"`
	Name            string  `gorm:"type:varchar(50);not null;comment:商品名"`
	GoodsSn         string  `gorm:"type:varchar(50);not null;comment:商品编号"`
	ClickNum        int32   `gorm:"type:int;default:0;not null;comment:点击数"`
	SoldNum         int32   `gorm:"type:int;default:0;not null;comment:已售数"`
	FavNum          int32   `gorm:"type:int;default:0;not null;comment:已售数"`
	ShipFree        bool    `gorm:"default:false;not null;comment:是否上架"`
	IsHot           bool    `gorm:"default:false;not null;comment:是否上架"`
	MarketPrice     float32 `gorm:"not null;comment:市场价"`
	ShopPrice       float32 `gorm:"not null;comment:本店价"`
	GoodsBrief      string  `gorm:"type:varchar(100);not null;default:''"`
	IsNew           bool    `gorm:"type:boolean;default:true"`
	Images          string  `gorm:"type:varchar(200)"`
	DescImages      string  `gorm:"type:varchar(200)"`
	GoodsFrontImage string  `gorm:"type:varchar(200);not null"`
}
